﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Templates/Acuicultura.Master" AutoEventWireup="true" CodeBehind="frmProduccion.aspx.cs" Inherits="EstadisticaProduce.Acuicultura.frmProduccion" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<script type="text/javascript">
    $(document).ready(function () {
        $("#<%=txtVolumen.ClientID %>").numeric();
        $("#<%=txtValor.ClientID %>").numeric();
        
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        function EndRequestHandler(sender, args) {

            $("#<%=txtVolumen.ClientID %>").numeric();
            $("#<%=txtValor.ClientID %>").numeric();
        }
    }); 
</script>

<script type="text/javascript">
    $(function () {
        InitializeDeleteConfirmation();

    });

    function InitializeDeleteConfirmation() {
        $('#deleteConfirmationDialog').dialog({
            autoOpen: false,
            resizable: false,
            height: 120,
            modal: true,
            buttons: {
                "Delete": function () {
                    $(this).dialog("close");
                    $(this).css("font-size:10px")
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            }
        });
    }

    function deleteItem(uniqueID, itemID) {
        var dialogTitle = 'Eliminar registro ' + itemID + '?';

        $("#deleteConfirmationDialog").html('<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Por favor confirme la eliminación del Registro</p>');

        $("#deleteConfirmationDialog").dialog({
            title: dialogTitle,
            buttons: {
                "Eliminar": function () { __doPostBack(uniqueID, ''); $(this).dialog("close"); },
                "Cancelar": function () { $(this).dialog("close"); }
            }
        });

        $('#deleteConfirmationDialog').dialog('open');
        return false;
    }

    function ShowError(errorMessage) {
        $(document).ready(function () {
            $("#deleteErrorDialog").text(errorMessage);
            $("#deleteErrorDialog").dialog({
                modal: true,
                buttons: {
                    Ok: function () {
                        $(this).dialog("close");
                        $(this).css("font-size", 11);
                    }
                }
            });
        });
    }
   </script>

<div id="deleteConfirmationDialog" style="font-size:10px;"></div>
<div id="deleteErrorDialog" title="Ocurrio un error, verifique." style="font-size:10px;"></div>

<center><b>PRODUCCION</b></center>

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
    <ContentTemplate>

<asp:HiddenField ID="hdnaccion" runat="server" />
<asp:HiddenField ID="hdncodempresa" runat="server" />
<asp:HiddenField ID="hdncodregistro" runat="server" />
<asp:HiddenField ID="hdncodestablecimiento" runat="server" />
<asp:HiddenField ID="hdnperiodo" runat="server" />

<div class="clsDivResultado" style="margin:auto;">
<table class="clsTabla" style="width:800px; text-align:left;" border="1" >
    <tr>
        <td>
            Especie
        </td>
        <td>
           Conservación
        </td>
        <td style="width:200px;">
           Presentación
        </td>
    </tr>

    <tr>
        <td>
           <asp:DropDownList ID="ddlEspecie" runat="server" CssClass="especie" 
                AutoPostBack="true" onselectedindexchanged="ddlEspecie_SelectedIndexChanged">
            </asp:DropDownList>
        </td>
        <td>
            <asp:DropDownList ID="ddlConservacion" runat="server" CssClass="conservacion">
            </asp:DropDownList>
        </td>
        <td>
            <asp:DropDownList ID="ddlPresentacion" runat="server" CssClass="presentacion">
            </asp:DropDownList>
        </td>
    </tr>
    <tr>
        <td>
           Volúmen
        </td>
        <td>
           Valor
        </td>
        <td>
           
        </td>
    </tr>
    <tr>
        <td>
           <asp:TextBox ID="txtVolumen" runat="server" MaxLength="10" CssClass="volumen" Text="0" Width="80px" />
           
        </td>
        <td>
            <asp:TextBox ID="txtValor" runat="server" MaxLength="10" CssClass="valor" Text="0" Width="80px" /> 
        </td>
        <td>
           
        </td>

    </tr>
    <tr>
        <td>
            Región           
        </td>
        <td>
           Planta Procesamiento
        </td>
        <td>
           
        </td>
    </tr>
    <tr>
        <td>
            <asp:DropDownList ID="ddlDepartamento" runat="server" CssClass="departamento" 
                AutoPostBack="true" onselectedindexchanged="ddlDepartamento_SelectedIndexChanged">
            </asp:DropDownList>
        </td>
        <td>
            <asp:DropDownList ID="ddlPlantaProc" runat="server" CssClass="planta">
            </asp:DropDownList>
        </td>
        <td>

        </td>
    </tr>
    <tr>
        <td>

        </td>
        <td colspan="3" style="text-align:right;">
            <asp:ImageButton ID="btnGraba" runat="server" CssClass="boton" 
                ImageUrl="~/Imagenes/Botones/u203_original.png" onclick="btnGraba_Click" />

            <asp:ImageButton ID="btnLimpia" runat="server" 
                ImageUrl="~/Imagenes/Botones/u201_original.png" onclick="btnLimpia_Click" />
        </td>
    </tr>

</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>

<br />

<div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    
     <asp:GridView ID="gvRegistro" runat="server" AllowPaging="false" 
        AllowSorting="false" AutoGenerateColumns="false" Width="850px"
        CssClass="clsTabla" onrowcommand="gvRegistro_RowCommand"
        DataKeyNames="codempresa,codperiodo,codespecie,desespecie,numvolumen,numvalor">
            <Columns>
                <asp:TemplateField HeaderText="Nro.">
                    <ItemTemplate>
                            <%#Convert.ToInt32(DataBinder.Eval(Container, "DataItemIndex")) + 1%>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Width="30px" />
                        <HeaderStyle CssClass="cl_cab_busca" ForeColor="#ffffff" />
                    </asp:TemplateField>

                    <asp:TemplateField HeaderText="Select">
                        <ItemTemplate>
                            <asp:CheckBox ID="chkSelect"  onclick="javascript:Check_Click(this);" runat="server"/>
                        </ItemTemplate>
                
                        <HeaderTemplate>
                        </HeaderTemplate>

                        <ItemStyle HorizontalAlign="Center" Width="30px"/>
                    </asp:TemplateField>

                    <asp:BoundField DataField="codempresa" HeaderText="cod_empresa" >
                        <ItemStyle CssClass="hiddencol" />
                        <HeaderStyle CssClass="hiddencol" />
                    </asp:BoundField>

                    <asp:BoundField DataField="codespecie" HeaderText="codespecie" >
                        <ItemStyle CssClass="hiddencol" />
                        <HeaderStyle CssClass="hiddencol" />
                    </asp:BoundField>
                    
                    <asp:BoundField DataField="desespecie" HeaderText="Especie">
                        <ItemStyle CssClass="hiddencols" />
                        <HeaderStyle CssClass="hiddencols" Width="150px" />
                    </asp:BoundField>

                    <asp:BoundField DataField="numvolumen" HeaderText="Volumen" DataFormatString="{0:N2}" >
                        <ItemStyle CssClass="hiddencols" HorizontalAlign="Right" />
                        <HeaderStyle CssClass="hiddencols" Width="70px"/>
                    </asp:BoundField>

                    <asp:BoundField DataField="numvalor" HeaderText="Valor" DataFormatString="{0:N2}" >
                        <ItemStyle CssClass="hiddencols" HorizontalAlign="Right" />
                        <HeaderStyle CssClass="hiddencols" Width="70px"/>
                    </asp:BoundField>

                    <asp:TemplateField HeaderText="Cantidad Usada">
                        <ItemTemplate>
                            <asp:TextBox ID="txtCantidad" runat="server" Text="" Width="70" MaxLength="10"/>
                        </ItemTemplate>
                        <ItemStyle Width="100px" HorizontalAlign="Center" />
                    </asp:TemplateField>
                        </Columns>
                        <RowStyle CssClass="RowStyle" />
                        <HeaderStyle CssClass="HeaderStyle" />
                        <AlternatingRowStyle CssClass="AlternatingRowStyle" />
             </asp:GridView>
 
 
 <script type = "text/javascript">

     function Check_Click(objRef) {
         //Get the Row based on checkbox
         var row = objRef.parentNode.parentNode;
         if (objRef.checked) {
             row.style.backgroundColor = "#C2D69B";
         }
         else {
             row.style.backgroundColor = "#F7F6F3";
         }

         //Get the reference of GridView
         var GridView = row.parentNode;
         //Get all input elements in Gridview
         var inputList = GridView.getElementsByTagName("input");

         for (var i = 0; i < inputList.length; i++) {
             //The First element is the Header Checkbox
             var headerCheckBox = inputList[0];
             //Based on all or none checkboxes are checked check/uncheck Header Checkbox
             var checked = true;
             if (inputList[i].type == "checkbox" && inputList[i] != headerCheckBox) {

                 if (!inputList[i].checked) {
                     checked = false;
                     break;
                 }
             }
         }
     }

</script>       
        
      <asp:Panel ID="pnlMensaje" runat="server" Visible="false" style="padding-top:30px; border:dotted 1px #222; width:700px; margin:auto; height:60px; font-size:medium; color:#3c9fff; font-weight:bold; text-align:center;">
          
          <asp:Label ID="lblMensaje" runat="server"/>

      </asp:Panel>
    
    </ContentTemplate>
    </asp:UpdatePanel>

</div>


</asp:Content>
